Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a decorator to quit pygame #766

Closed
wants to merge 13 commits into from
Closed

Conversation

mgaitan
Copy link
Collaborator

@mgaitan mgaitan commented Apr 16, 2018

This fix #575

@coveralls
Copy link

coveralls commented Apr 16, 2018

Coverage Status

Coverage decreased (-0.2%) to 65.185% when pulling fe917ce on mgaitan:pygame_quit into b0f09c7 on Zulko:master.

@tburrows13 tburrows13 added the bug-fix For PRs and issues solving bugs. label Apr 17, 2018
@tburrows13
Copy link
Collaborator

I'm running:

clip = VideoFileClip("media/big_buck_bunny_0_30.webm").subclip(0,1)
clip.preview()
time.sleep(10)

with this PR and, after playing the video for a second, it crashes (doesn't sleep for 10 secs):

2018-04-22 18:58:17.403 python[2873:132770] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
Traceback (most recent call last):
  File "tom_t.py", line 7, in <module>
    clip.preview()
  File "<decorator-gen-102>", line 2, in preview
  File "/Users/tomburrows/Python/moviepy-dev/moviepy/moviepy/decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-101>", line 2, in preview
  File "/Users/tomburrows/Python/moviepy-dev/moviepy/moviepy/decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "<decorator-gen-100>", line 2, in preview
  File "/Users/tomburrows/Python/moviepy-dev/moviepy/moviepy/decorators.py", line 142, in pygame_quit
    value = f(*a, **k)
  File "/Users/tomburrows/Python/moviepy-dev/moviepy/moviepy/video/io/preview.py", line 135, in preview
    for event in pg.event.get():
pygame.error: video system not initialized

When run on the master branch, after a second of video, the last frame just sits there for 10 seconds, then disappears.

@mgaitan
Copy link
Collaborator Author

mgaitan commented Apr 22, 2018

I will check, thanks for test it.

@tburrows13 tburrows13 added breaking-change Must not merge without proper approval. Requires full documentation (own section) in the changelog. and removed bug-fix For PRs and issues solving bugs. labels Apr 23, 2018
@mgaitan
Copy link
Collaborator Author

mgaitan commented Apr 30, 2018

@tburrows13 I've updated the decorator to catch pygame.error . This solves the issue you was seeing and then do the sleep. In the other hand, the same code in master in my computer freeze the preview window. Check the capture
captura de pantalla de 2018-04-29 20-41-49

@tburrows13
Copy link
Collaborator

It appears that in the past we've never imported pygame in the test environment, so here its raising an error because its not installed.

@tburrows13
Copy link
Collaborator

Ok, I've removed the tests for now, pygame will require some setting up with SDL on Travis, and I have no idea if that would ever work.

@mondeja
Copy link
Collaborator

mondeja commented Apr 15, 2021

This could be a good idea, but:

  • Doesn't solves the problem fixed by Update preview.py, fix issue #575 #1537 of quitting pygame when a key is pressed.
  • Catching all whatever pygame error passing it seems to me very risky.
  • The code and the testing environment is conflicting a lot with current codebase.

For these reasons, I'm closing this to reduce the future reviewing work. Feel free to update this code and reopen the pull if you think that could be interesting 👍

@mondeja mondeja closed this Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Must not merge without proper approval. Requires full documentation (own section) in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On windows, a preview doesn't close when you quit.
4 participants